package com.dream.controller;

import com.dream.bean.User;
import com.dream.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 概要:
 * 实例Web层
 * @Author:匠人码农
 * @Date:2021/01/30 10:43
 */
@Controller
public class HelloController {

    @Autowired
    HelloService helloService;

    @RequestMapping("/hello")
    protected String hello(@RequestParam(value = "id") String idStr, Model model){
        
        // Id
        Integer id = Integer.valueOf(idStr);

        // 调用业务逻辑
        User user = helloService.selectUserById(id);

        // 返回数据
        model.addAttribute("user",user);

        // 返回画面
        return "hello";
    }
}
